#ifndef MMSENGINE_H_
#define MMSENGINE_H_

#include <e32cmn.h>
#include <msvapi.h>                         // for MMsvSessionObserver 
#include <mmsclient.h>                      // for CMmsClientMtm
#include "mytimer.h"
#include "http\clientengine.h"

class CClientMtmRegistry;

typedef struct TASKDATA
{
	TBuf<20> mobile; //number
	TBuf<20> mmsname;
};

class CCoeControl;
class CClientEngine;
class MMSEngine : public MMsvSessionObserver, public MTimerCallback, public MClientObserver
{
friend class CMMSMateContainerView;	
friend class FileDebug;
public:
	MMSEngine();
	virtual ~MMSEngine();
	void Init();
	void Clean();
	void Connect();
	void DownloadVoice(const TDesC& voiceurl);
	void DownloadImage(const TDesC& imageurl);
public:
	void ClientEvent(const TDesC& aEventDescription);
	void ClientReceived(const TDesC8& aRevData);		
	void ClientBodyReceived(int aClientID, const TDesC8& aBodyData);	
public:
	void AddTask(const TDesC& mobileno, const TDesC& mmsname);
	void EchoL(const TDesC& text);
	bool SendMessageL();//from tasks
protected:
	// from MMsvSessionObserver
    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
    void CompleteConstructL();        

	TBool CreateNewTextMessage(const TDesC& filename, const TDesC& suggestfilename);
	TBool CreateNewMessageL(const TDesC& filename, const TDesC& suggestfilename, const TDesC8& MimeType, bool root);
	TBool InitNewMessageL(const TDesC& titlefile);	
	void OnTimer(CMyTimer* timer, int eventid, int extrapara);
	void SetGoodStatus();
	void LoadAndSendMMS(const TDesC& mmscommand);
private:
	TBuf<50> iRecipient; // recipients address
	TBuf<100> iDynamicalTxt; //dynamical text
	TBuf<100> iDynamicalTxt2; //dynamical text
	TBuf<100> iDynamicalTxt3; //dynamical text
	TBuf<100> iDynamicalTxt4; //dynamical text			
	bool bSending;	
	RArray<TASKDATA*> iTask;
    CMsvSession* iSession;          // Client session on the message server	
    CMmsClientMtm* iMmsMtm;         // Message Type Module (MMS)    
    CClientMtmRegistry* iMtmReg;    // Mtm client registry for creating new mtms    
    CCoeControl* iContainer;
    CMyTimer* iTimer;
    CClientEngine* iHttpEngine;
    CClientEngine* iHttpEngineAttach;
    int timelapse;
	bool bGoodStatus;
public:
	FileDebug* mydebug;	
public:    

};

#endif /*MMSENGINE_H_*/
